package main

import "fmt"

func main() {

	input := [][]int{[]int{2,0}, []int{1,1}, []int{0,2}, []int{2,1}, []int{1,2},[]int{1,0},[]int{0,0},[]int{0,1}}
	res := tictactoe(input)
	fmt.Println(res)
}

func tictactoe(moves [][]int) string {
	Checkerboard := [][]string{}
	for i := 0; i < 3; i++ {
		Checkerboard = append(Checkerboard, make([]string, 3))
	}
	for i, input := range moves {
		if i%2 == 0 {
			if Checkerboard[input[0]][input[1]] == ""{
				Checkerboard[input[0]][input[1]] = "X"
			}
		} else {
			if Checkerboard[input[0]][input[1]] == ""{
				Checkerboard[input[0]][input[1]] = "O"

			}

		}

		if i >=3 {


			if Checkerboard[0][0] == "X" {
				if Checkerboard[0][1] == "X" && Checkerboard[0][2] == "X" {
					return "A"
				} else if Checkerboard[1][1] == "X" && Checkerboard[2][2] == "X" {
					return "A"
				}else if  Checkerboard[1][0] == "X" && Checkerboard[2][0] == "X" {
					return "A"
				}

			}
			if Checkerboard[1][0] == "X" && Checkerboard[1][1] == "X" && Checkerboard[1][2] == "X" {
				return "A"
			}
			if Checkerboard[2][0] == "X" && Checkerboard[2][1] == "X" && Checkerboard[2][2] == "X" {
				return "A"
			}
			if Checkerboard[0][2] == "X" && Checkerboard[1][1] == "X" && Checkerboard[2][0] == "X" {
				return "A"
			}
			if Checkerboard[0][1] == "X" && Checkerboard[1][1] == "X" && Checkerboard[2][1] == "X" {
				return "A"
			}
			if Checkerboard[0][2] == "X" && Checkerboard[1][2] == "X" && Checkerboard[2][2] == "X" {
				return "A"
			}
			if Checkerboard[0][0] == "O" {
				if Checkerboard[0][1] == "O" && Checkerboard[0][2] == "O" {
					return "B"
				} else if Checkerboard[1][1] == "O" && Checkerboard[2][2] == "O" {
					return "B"
				}else if  Checkerboard[1][0] == "O" && Checkerboard[2][0] == "O" {
					return "B"
				}

			}
			if Checkerboard[1][0] == "O" && Checkerboard[1][1] == "O" && Checkerboard[1][2] == "O" {
				return "B"
			}
			if Checkerboard[2][0] == "O" && Checkerboard[2][1] == "O" && Checkerboard[2][2] == "O" {
				return "B"
			}
			if Checkerboard[0][2] == "O" && Checkerboard[1][1] == "O" && Checkerboard[2][0] == "O" {
				return "B"
			}
			if Checkerboard[0][1] == "O" && Checkerboard[1][1] == "O" && Checkerboard[2][1] == "O" {
				return "B"
			}
			if Checkerboard[0][2] == "O" && Checkerboard[1][2] == "O" && Checkerboard[2][2] == "O" {
				return "B"
			}
		}
		}

	if len(moves) == 9{
		return "Draw"
	}else {
		return "Pending"
	}
}
